﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    x:Class="Flare.ItemTemplate"
                    xmlns:conv="clr-namespace:Flare.Converter">

    <SolidColorBrush x:Key="DefaultTextColor" Color="#FF666666"/>
    <SolidColorBrush x:Key="SlaveTextColor" Color="#FF565656"/>
    <SolidColorBrush x:Key="DefaultHardListItemBackgroundColor" Color="#FFDCE2E0" />
    <SolidColorBrush x:Key="SelectHardListItemBackgroundColor" Color="#FFD4F1EC" />

    <SolidColorBrush x:Key="BackColorHistoryItem" Color="#FFB4E2E4"/>


    <Style x:Key="InventoryListItemTemplate" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Background" Value="{StaticResource ColorGreyPastel}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="root" Background="{TemplateBinding Background}" Margin="5">
                        <StackPanel Orientation="Vertical" TextBlock.Foreground="{StaticResource ColorTextBackground}" TextBlock.FontSize="14">
                            <TextBlock Text="{Binding Path=ip}" Margin="10,10,10,0" />
                            <TextBlock x:Name="pin_osblid" Text="Устаревшая ОС" Margin="15,5,10,0" />
                            <TextBlock x:Name="pin_proc" Text="Слабый процессор" Margin="15,5,10,0" />
                            <TextBlock x:Name="pin_memory" Text="Мало ОП" Margin="15,5,10,0" />
                            <TextBlock x:Name="pin_hard" Text="Критично места на ЖД" Margin="15,5,10,10" />
                        </StackPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=oldosbild}" Value="true" >
                            <Setter Property="Foreground" Value="{StaticResource ColorInputText}" TargetName="pin_osblid" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=lowmemory}" Value="true" >
                            <Setter Property="Foreground" Value="{StaticResource ColorInputText}" TargetName="pin_memory" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=slowprocessor}" Value="true" >
                            <Setter Property="Foreground" Value="{StaticResource ColorInputText}" TargetName="pin_proc" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=lowrootspace}" Value="true" >
                            <Setter Property="Foreground" Value="{StaticResource ColorInputText}" TargetName="pin_hard" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style x:Key="HardListItemTemplate" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Background" Value="{StaticResource ColorGreyPastel}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseLayoutRounding" Value="False" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border Background="{TemplateBinding Background}" Style="{StaticResource StyleBorderZoomed}">
                        <StackPanel  Orientation="Vertical" >
                            <TextBlock Text="{Binding Path=room}" FontSize="12" Foreground="{StaticResource DefaultTextColor}"
                                       FontFamily="Segoe UI" Margin="10,10,10,0" />

                            <TextBlock Text="{Binding Path=teh_type}" FontSize="20" Foreground="{StaticResource SlaveTextColor}"
                                       FontFamily="Segoe UI" Margin="15,0,10,0" />

                            <TextBlock Text="{Binding Path=mark_model}" FontSize="15" Foreground="{StaticResource DefaultTextColor}"
                                       FontFamily="Segoe UI Ligth" Margin="15,10,10,0" />

                            <TextBlock Text="{Binding Path=inventory_number, StringFormat='Инвентарный номер {0}'}" FontSize="12" 
                                       Foreground="{StaticResource DefaultTextColor}" FontFamily="Segoe UI" Margin="15,0,10,10" />
                        </StackPanel>

                    </Border>

                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=id_type}" Value="1">
                            <Setter Property="Background" Value="{StaticResource ColorGreenPastel}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=id_type}" Value="2">
                            <Setter Property="Background" Value="{StaticResource ColorBluePastel}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=id_type}" Value="3">
                            <Setter Property="Background" Value="{StaticResource ColorRedPastel}" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <DataTemplate x:Key="HardListMoveHistoryTemplate">
        <Border x:Name="root" BorderThickness="2" BorderBrush="Transparent" Margin="0,10,0,10">
            <Border.Style>
                <Style TargetType="{x:Type Border}">
                    <Setter Property="HorizontalAlignment" Value="Stretch" />
                    <Setter Property="VerticalAlignment" Value="Top" />
                    <Setter Property="MinWidth" Value="180" />
                    <Setter Property="Focusable" Value="False" />
                    <Setter Property="Background" Value="{StaticResource BackColorHistoryItem}" />
                    <Setter Property="UseLayoutRounding" Value="True" />
                </Style>
            </Border.Style>
            <StackPanel Orientation="Vertical" Margin="10" >
                <TextBlock Text="{Binding Path=move_date, StringFormat={}{0:yyyy.MM.dd HH:mm}}" FontSize="16" Foreground="{StaticResource DefaultTextColor}" 
                           FontFamily="Segoe UI"/>

                <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
                    <TextBlock Text="источник" FontSize="12" Foreground="{StaticResource DefaultTextColor}" FontFamily="Segoe UI" />
                    <TextBlock Text="{Binding Path=from_room}" FontSize="14" Foreground="{StaticResource DefaultTextColor}" FontFamily="Segoe UI" Margin="10,0,0,0"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="получатель" FontSize="12" Foreground="{StaticResource DefaultTextColor}" FontFamily="Segoe UI"/>
                    <TextBlock Text="{Binding Path=to_room}" FontSize="14" Foreground="{StaticResource DefaultTextColor}" FontFamily="Segoe UI" Margin="10,0,0,0"/>
                </StackPanel>
                <TextBlock Text="{Binding Path=description}" FontSize="12" Foreground="{StaticResource DefaultTextColor}" FontFamily="Segoe UI" Margin="10,0,0,0" 
                           TextWrapping="Wrap" />
            </StackPanel>
        </Border>
    </DataTemplate>

    <!-- Адресное пространство -->
    <Style x:Key="NetworkListItemTemplate" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Background" Value="{StaticResource DefaultHardListItemBackgroundColor}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="root" Background="{TemplateBinding Background}" Style="{StaticResource StyleBorderZoomed}">
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding Path=room}" FontSize="12" Foreground="{StaticResource DefaultTextColor}"
                                       FontFamily="Segoe UI"  Margin="10,10,10,0" MouseLeftButtonDown="Test" />

                            <TextBlock Text="{Binding Path=name}"
                                       FontSize="20"
                                       Foreground="{StaticResource SlaveTextColor}"
                                       FontFamily="Segoe UI"
                                       Margin="15,0,10,0" TextTrimming="CharacterEllipsis"/>

                            <TextBlock Text="{Binding Path=phone}"
                                       FontSize="15"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       FontFamily="Segoe UI Ligth"
                                       Margin="15,0,0,10"/>

                            <TextBlock Text="{Binding Path=ip}"
                                       FontSize="12"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       FontFamily="Segoe UI"
                                       Margin="15,0,10,10"/>
                        </StackPanel>
                    </Border>
                    
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=id_type}" Value="1">
                            <Setter Property="Background" Value="{StaticResource ColorGreenPastel}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=id_type}" Value="2">
                            <Setter Property="Background" Value="{StaticResource ColorBluePastel}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=id_type}" Value="3">
                            <Setter Property="Background" Value="{StaticResource ColorRedPastel}" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ProviderItemTemplate" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Background" Value="{StaticResource DefaultHardListItemBackgroundColor}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="root" Background="{TemplateBinding Background}" Style="{DynamicResource StyleBorderZoomed}">
                        <StackPanel  Orientation="Vertical" >
                            <TextBlock Text="{Binding Path=provider}" FontSize="16" Foreground="{StaticResource DefaultTextColor}" Margin="8,4" TextWrapping="Wrap"/>
                            <TextBlock Text="{Binding Path=provider_address}" FontSize="14" Foreground="{StaticResource DefaultTextColor}" Margin="8,4" TextWrapping="Wrap"/>
                            <TextBlock Text="{Binding Path=default_contract_number}" FontSize="14" Foreground="{StaticResource DefaultTextColor}" Margin="8,4" TextWrapping="Wrap"/>
                        </StackPanel>

                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{StaticResource ColorActiveElement}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ContractListItemTemplate" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Background" Value="{StaticResource DefaultHardListItemBackgroundColor}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="root" Background="{TemplateBinding Background}" Style="{DynamicResource StyleBorderZoomed}">
                        <StackPanel  Orientation="Vertical" >
                            <TextBlock Text="{Binding Path=department}"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       FontFamily="Segoe UI Ligth"
                                       Margin="8,8,8,0"/>

                            <TextBlock Text="{Binding Path=service}"
                                       FontSize="20"
                                       Foreground="{StaticResource SlaveTextColor}"
                                       Margin="12,0,8,0"/>

                            <TextBlock Text="{Binding Path=provider}"
                                       FontSize="14"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       Margin="12,8,8,0" />

                            <TextBlock Text="{Binding Path=contract_number}"
                                       FontSize="14"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       Margin="12,2,8,0" />

                            <TextBlock Text="{Binding Path=contract_description}"
                                       FontSize="14"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       Margin="12,2,8,8"/>
                        </StackPanel>

                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{StaticResource ColorActiveElement}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DepartamentItemTemplate" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Background" Value="{StaticResource DefaultHardListItemBackgroundColor}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="root" Background="{TemplateBinding Background}" Style="{DynamicResource StyleBorderZoomed}">
                        <StackPanel  Orientation="Vertical" >
                            <TextBlock Text="{Binding Path=department}"
                                       FontSize="16"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       FontFamily="Segoe UI Ligth"
                                       Margin="8,4"/>

                            <TextBlock Text="{Binding Path=department_address}"
                                       FontSize="14"
                                       Foreground="{StaticResource SlaveTextColor}"
                                       Margin="8,4"/>

                            <TextBlock Text="{Binding Path=department_contact}"
                                       FontSize="14"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       Margin="8,4" />

                            <TextBlock Text="{Binding Path=department_contact_phone}"
                                       FontSize="14"
                                       Foreground="{StaticResource DefaultTextColor}"
                                       Margin="8,4" />
                        </StackPanel>

                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{StaticResource ColorBluePastel}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="EqMoveItemTemplate" TargetType="{x:Type ListBoxItem}">
        <!--<Setter Property="Background" Value="{StaticResource ColorBluePastel}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="root" Background="{TemplateBinding Background}" Style="{StaticResource StyleBorderZoomed}">
                        <StackPanel Orientation="Vertical" TextBlock.Foreground="{StaticResource ColorText}" TextBlock.FontSize="12">
                            <TextBlock Text="{Binding move_date, Mode=OneWay, StringFormat={}{0:yyyy.dd.MM HH:mm}}" Margin="10,10,10,0" />
                            <TextBlock Text="{Binding Path=tech_name}" Margin="10,0,10,0"/>
                            <TextBlock Text="{Binding Path=inventory_number}" Margin="10,0,0,0"/>
                            <TextBlock Text="{Binding Path=from_room}" Margin="10,0,0,0"/>
                            <TextBlock Text="{Binding Path=to_room}" Margin="10,0,0,0"/>
                            <TextBlock Text="{Binding Path=author}" Margin="10,0,0,10" FontSize="8"/>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>-->


        <Setter Property="Margin" Value="4" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border BorderBrush="{StaticResource ColorBorder}" BorderThickness="1" SnapsToDevicePixels="True">
                        <Grid Margin="4" TextBlock.Foreground="{StaticResource ColorText}" TextBlock.FontSize="14">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="150" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Text="{Binding move_date, Mode=OneWay, StringFormat={}{0:yyyy.dd.MM HH:mm}}" />
                            <TextBlock Text="{Binding tech_name}" Grid.Column="1"/>
                            <TextBlock Text="{Binding inventory_number}" Grid.Column="2"/>
                            <TextBlock Text="{Binding room}" Grid.Column="3"/>
                            <TextBlock Text="{Binding author}" Grid.Column="5"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style x:Key="PrimitiveItemTemplate" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Background" Value="{StaticResource DefaultHardListItemBackgroundColor}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="root" Background="{TemplateBinding Background}" Style="{DynamicResource StyleBorderZoomed}">
                        <ContentPresenter x:Name="ContentSite" TextElement.FontSize="16" OverridesDefaultStyle="True" HorizontalAlignment="Stretch" 
                                          VerticalAlignment="Stretch" Margin="8,16" TextBlock.Foreground="{StaticResource DefaultTextColor}" />
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{StaticResource ColorBluePastel}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>